<template>
    <div>
        <div class="e-form">
             <BillTop @cancel="handleClose"></BillTop>
            <div class="tabs" style="margin-bottom:120px">
                <div class="tabs-title">基本信息</div>
                <div style="width: 100%" class="form">
                    <el-form :model="formData" :label-width="formLabelWidth" :rules="rulesBase" ref="ruleForm" class="demo-ruleForm">
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="机构：">
                                    <span>{{ formData.orgName }}</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="12">
                                <el-form-item label="录入人员：">
                                    <span>{{ formData.inputName }}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="12">
                                <el-form-item label="状态：">
                                    <span>{{ state.find(x=>x.value === formData.state).label }}</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="24">
                                <el-form-item label="备注：">
                                    <el-input type="textarea" v-model="formData.remarks" autocomplete="off"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
            </div>
            <div class="buttons">
                <el-button type="primary" size="small" style="background: #2e61d7" @click="addSave"
                    >保存</el-button
                >
                <el-button size="small" @click="handleClose">取消</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import { mapState } from 'vuex'
import auditRequest from '@/api/settlementManagement/peripheralMaterial/peripheralMaterial.js'
import { showLoading, hideLoading } from '@/utils/common'
export default {
    data () {
        return {
            //基础信息
            formData: {
                baseCurId: '', //本位币id
                baseCurName: '', //本位币名称、
                baseSettleAmount: 0,
                billId: '',
                billNo: '',
                businessType: 2,
                currency: '',
                inputId: '',
                inputName: '',
                isRed: 0,
                isSharing: 0,
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: '',
                nullifyDescription: '',
                nullifyReason: '',
                orgId: '',
                orgName: '',
                parentId: '',
                remarks: '',
                settleAmount: 0,
                settleDate: '',
                settleOrgId: '',
                settleOrgName: '',
                sourceId: '',
                sourceNo: '',
                state: 0,
                taxAmount: 0,
                taxRate: 0,
                totalSettleAmount: 0,
                workId: '',
                redState: -1
            },
            formLabelWidth: '200px',
            billid: '',
        }
    },
    async mounted () {
        if (this.$route.query.isRedSingle === '1') {
            // alert(this.$route.query.billid + 'xxx')
            this.formData = await auditRequest.chonghongdan2({ billId: this.$route.query.billid })
        }else{
            const { baseCyByOrgId } = this.userInfo
            console.log(this.userInfo, 'rr')

            this.formData.inputName = this.userInfo.userName  //录入人员
            this.formData.inputId = this.userInfo.userId

            this.formData.orgName = this.userInfo.orgInfo.orgName
            this.formData.orgId = this.userInfo.orgInfo.orgId

            this.formData.baseCurName = baseCyByOrgId.currencyName  //本位币
            this.formData.baseCurId = baseCyByOrgId.currency
        }

    },
    components: {
    },
    computed: {
        ...mapState({
            userInfo: state => state.userInfo,
            currencyForm: state => state.equip.equipData.currencyForm, //币种
            state: state => state.equip.equipData.state, //通用流程状态
        })
    },
    methods: {
        //新增基本信息
        addSave () {
            showLoading()

            auditRequest.adddbjs(this.formData).then(res=>{
                this.clientPop('info', '保存成功!是否进行下一步操作？', ()=>{
                    this.$router.push({
                        path: '/peripheralMaterialEdit',
                        query: {
                            billid: res,
                            name: 'planDetail'
                        }
                    })
                },
                null,
                this.handleClose
                )
            })

        },
        //取消
        handleClose () {
            hideLoading()
            this.$router.replace('/peripheralMaterialList')
        },
    },
}

</script>

<style lang='scss' scoped>
.buttons {
    left: 0;
}
.e-form {
    padding: 0 20px;
    .tabs-title::before {
        content: '';
        height: 22px;
        width: 8px;
        border-radius: 40px;
        background-color: #2e61d7;
        display: block;
        position: absolute;
        left: 20px;
        margin-right: 20px;
    }
}
.e-table{
    min-height: auto;
    background: #fff;
}
.separ{
   width: 30px;
   height: 40px;
   line-height: 18px;
   text-align: center;
}
.upload {
    margin: 20px auto;
    display: flex;
    justify-content: center;
    text-align: center;
}

.upload-demo {
    display: flex;
    justify-content: center;
    align-items: center;
}

::v-deep.el-input--suffix .el-input__inner {
    padding-right: 5px;
}
::v-deep.el-table .cell {
    text-align: center;
}
</style>